package com.canaan.business.controller.pc.api.erp;

import cn.hutool.core.lang.Pair;
import cn.hutool.json.JSONUtil;
import com.canaan.business.domain.basic.ErpProduct;
import com.canaan.business.domain.vo.ErpProductVo;
import com.canaan.business.domain.vo.GoodInfoVo;
import com.canaan.business.domain.vo.GoodsVo;
import com.canaan.business.domain.vo.StockAdjustVo;
import com.canaan.business.service.basic.IErpProductService;
import com.canaan.common.annotation.ApiInterfaceLog;
import com.canaan.common.core.controller.BaseController;
import com.canaan.common.core.domain.AjaxResult;
import com.canaan.common.encrypt.PushEdiService;
import com.canaan.system.service.ISysConfigService;
import com.github.pagehelper.util.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 库存Controller
 *
 * @author ruoyi
 * @date 2022-11-30
 */
@Api(tags = "库存")
@RestController
@RequestMapping("/erp/stock")
public class StockController extends BaseController {
    @Resource
    private ISysConfigService sysconfig;

    /**
     * 库存校准
     */
    @ApiOperation(value = "库存校准")
    @ApiInterfaceLog(title = "库存校准")
    @PostMapping("/adjust")
    public AjaxResult adjust(@RequestBody StockAdjustVo stockAdjustVo) {
        StockAdjustVo vo = new StockAdjustVo();
        vo.setStockCode("20400041485");
        vo.setOwner("20000005285");
        vo.setStockStatus(1);
        vo.setCompareDate("2025032908");
        vo.setCompareBatchNo("2025032901");
        vo.setOverFlag(1);
        List<GoodInfoVo> items = new ArrayList<>();
        GoodInfoVo vo1 = new GoodInfoVo();
        vo1.setSpecCode("SPU0000002675001");
        vo1.setBatchNo("20250329");
        vo1.setStockNum("10001");
        items.add(vo1);
        vo.setItems(items);
        Pair<Boolean, String> result = PushEdiService.push(sysconfig.selectConfigByKey("edi.compare"), JSONUtil.toJsonStr(vo));

        return success();
    }

}
